package com.leyou.item.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.leyou.common.exception.LyException;
import com.leyou.item.dto.SkuDTO;
import com.leyou.item.entity.Sku;
import com.leyou.item.mapper.SkuMapper;
import com.leyou.item.service.SkuService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils;

import java.util.List;

/**

 */
@Service
public class SkuServiceImpl extends ServiceImpl<SkuMapper, Sku> implements SkuService {


    @Override
    public List<SkuDTO> querySkuListByIds(List<Long> ids) {
        if (CollectionUtils.isEmpty(ids)) {
            throw new LyException(400, "sku的查询id不能为空!");
        }
        return SkuDTO.convertEntityList(listByIds(ids));
    }

    @Override
    public List<SkuDTO> querySkuListBySpuId(Long cid) {

        return SkuDTO.convertEntityList(this.query().eq("spu_id", cid).list());
    }

}
